USE [ERP]
GO

/****** Object:  StoredProcedure [dbo].[SP_COMPANY_INFO_UPDATE_INSERT]    Script Date: 11/16/2009 14:37:44 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

-- =============================================
-- Author:		Yaser
-- Create date: Jul 17 09
-- =============================================
CREATE PROCEDURE [dbo].[SP_COMPANY_INFO_UPDATE_INSERT]
	@CID nvarchar(50),
	@Name nvarchar(50),
	@Address nvarchar(50),
	@PhoneNumber nvarchar(50),
	@FaxNumber nvarchar(50),
	@EmailAddress nvarchar(50),
	@WebSite nvarchar(50),
	@SocialSecurityNumber nvarchar(50),
	@TaxCode nvarchar(50)	
AS
BEGIN	

	-- since the system supports just one company, the table shouldn't contain more than one
	UPDATE Company SET
		Name = @Name ,
		Address = @Address ,
		PhoneNumber =@PhoneNumber,
		FaxNumber = @FaxNumber,
		EmailAddress = @EmailAddress,
		WebSite  = @WebSite ,
		SocialSecurityNumber  = @SocialSecurityNumber ,
		TaxCode = @TaxCode
		
	IF @@ROWCOUNT <= 0 
	BEGIN	
		INSERT INTO Company (ID, Name ,Address,PhoneNumber,FaxNumber,EmailAddress,WebSite,SocialSecurityNumber,TaxCode)
		VALUES (@CID, @Name,@Address,@PhoneNumber,@FaxNumber,@EmailAddress,@WebSite,@SocialSecurityNumber,@TaxCode)				
	END
	
	RETURN @@ROWCOUNT
END

GO

